package com.AJava1710D.lock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * 作者: LCG
 * 日期: 2020/6/28 08:36
 * 描述:
 */
public class ThreadReen1  extends Thread{

    private ReentrantLock reentrantLock;

    public ThreadReen1(ReentrantLock reentrantLock) {
        this.reentrantLock = reentrantLock;
    }

    @Override
    public void run() {

        reentrantLock.lock();
        try{
            for (int i=0;i<10;i++){
                try {
                    Thread.sleep(500);
                    TestRennlock.a++;
                    System.out.println("============"+Thread.currentThread().getName());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }finally {
            reentrantLock.unlock();
        }



    }
}
